Ext.define('App.datasource.view.SourceTableList', {
    extend: 'Extend.grid.CrudGridPanel',
    alias: 'widget.SourceTableList',
    requires: ['App.datasource.model.SourceTableViewModel'],
    viewModel: 'SourceTableViewModel',
    border: false,
    sortableColumns: false,
    config: {
        tbar: {
            quickCreate: {
                hidden: true
            },
            add: {
                before: '',
                index: 5,
                text: '补齐数据'
            }
        }
    },
    extraParams: function () {
        return {
            'projectId': this.projectId,
            'tableName': this.dataTable.tableName
        }
    },
    bind: {
        store: '{Query}',
        search: '{search}'
    },
    editor: {
        formClazz: 'App.datasource.view.SourceTableEditor',
        save: 'source_table/save',
        get: 'source_table/get_by_id',
        del: 'source_table/deletes',
        dataType: 'Report',
        model: 'App.datasource.model.SourceTableModel'
    },
    initComponent: function () {
        var me = this;
        me.callParent(arguments);
    },
    addHandler: function () {
        var me = this;
        var getUrl = 'source_table/repair_teration_data'
        if (this.dataTable.type == 'project') {
            getUrl = 'source_table/repair_project_data'
        }
        me.mask('补齐数据...');
        Ext.Ajax.request({
            url: getUrl,
            params: {
                projectId: me.projectId,
                tableName: me.dataTable.tableName
            },
            success: function (resp) {
                if (resp.result.success == true) {
                    me.reload();
                    Extend.Msg.info('提示', resp.result.result)
                }
            }, callback: function () {
                me.unmask();
            }
        });
    },
    editHandler: function () {
        this.callParent(arguments);
    }
})